#include<bits/stdc++.h>
using namespace std;
int t,n,a[100],b[100],c[100],ans,k1,k2,wc;
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
while(t--){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }ans=0;
    for(int i=0;i<(1<<n+1)-1;i++){
        k1=0,k2=0,wc=0;
        for(int j=1;j<=n+1;j++){
                cout<<(i&(1<<j));
            if(i&(1<<j)){
                b[k1++]=a[j];
            }
            else{
                c[k2++]=a[j];
            }
        }
        cout<<"\n";
for(int i=1;i<k1-1;i++){
    if(b[i]==b[i-1]){
        wc+=b[i];
    }
}
for(int i=1;i<k2-1;i++){
    if(c[i]==c[i-1]){
        wc+=c[i];
    }
}
ans=max(ans,wc);
    }


        cout<<ans;

}
}
